home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / USB / Mac OS USB DDK v1.2 / Examples / USBKeypad / USBKeypadHeader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  4.5 KB  |  141 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        USBKeypadHeader.c
  3.  
  4.     Contains:    Keyboard Module Header file
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #include <Types.h>
  13. #include <Devices.h>
  14. #include <DriverServices.h>
  15. #include <USB.h>
  16.  
  17. #include "USBKeypad.h"
  18. #include "USBKeypadVersion.h"
  19.  
  20. static     OSStatus     MacAllyTenKeyDeviceInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  21. static     OSStatus     MacAllyTenKeyFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
  22. static     OSStatus     MacAllyTenKeyInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  23. static    OSStatus     MacAllyTenKeyDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
  24.  
  25. extern    usbMacAllyPBStruct myParamBlock;
  26.  
  27. //------------------------------------------------------
  28. //
  29. //    This is the driver description structure that the expert looks for first.
  30. //  If it's here, the information within is used to match the driver
  31. //  to the device whose descriptor was passed to the expert.
  32. //    Information in this block is also used by the expert when an
  33. //  entry is created in the Name Registry.
  34. //
  35. //------------------------------------------------------
  36. USBDriverDescription    TheUSBDriverDescription = 
  37. {
  38.     // Signature info
  39.     kTheUSBDriverDescriptionSignature,
  40.     kInitialUSBDriverDescriptor,
  41.     
  42.     // Device Info
  43.     0x0618,                                    // vendor = not device specific
  44.     0x0300,                                    // product = not device specific
  45.     0,                                        // version of product = not device specific
  46.     0,                                        // protocol = not device specific
  47.     
  48.     // Interface Info    (* I don't think this would always be required...*)                
  49.     0,                                        // Configuration Value
  50.     0,                                        // Interface Number
  51.     0,                                        // Interface Class
  52.     0,                                         // Interface SubClass
  53.     0,                                        // Interface Protocol
  54.         
  55.     
  56.     // Driver Info
  57.     "\pUSBHIDMacAllyTenKey",                // Driver name for Name Registry
  58.     0,                                        // Device Class  (from USBDeviceDefines.h)
  59.     0,                                        // Device Subclass 
  60.     kKBDHexMajorVers, 
  61.     kKBDHexMinorVers, 
  62.     kKBDCurrentRelease, 
  63.     kKBDReleaseStage,                        // version of driver
  64.     
  65.     // Driver Loading Info
  66.     kUSBProtocolMustMatch+kUSBDoNotMatchInterface+kUSBDoNotMatchGenericDevice                    // Flags (currently undefined)
  67. };
  68.  
  69. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  70. {
  71.     kClassDriverPluginVersion,                // Version of this structure
  72.     MacAllyTenKeyDriverValidateHW,            // Hardware Validation Procedure
  73.     MacAllyTenKeyDeviceInitialize,            // Initialization Procedure
  74.     MacAllyTenKeyInterfaceInitialize,        // Interface Initialization Procedure
  75.     MacAllyTenKeyFinalize,                    // Finalization Procedure
  76.     0,                                        // Driver Notification Procedure
  77. };
  78.     
  79.     
  80. // Initialization function
  81. // Called upon load by Expert
  82. static     OSStatus     MacAllyTenKeyDeviceInitialize (USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
  83. {
  84.     DriverEntry(device, pDesc, busPowerAvailable);
  85.     return (OSStatus)noErr;
  86. }
  87.  
  88. // Interface Initialization Initialization function
  89. // Called upon load by Expert
  90. static     OSStatus     MacAllyTenKeyInterfaceInitialize (UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device)
  91. {
  92. #pragma unused (pInterface)
  93. #pragma unused (pDesc)
  94. #pragma unused (device)
  95. #pragma unused (interfacenum)
  96.     USBExpertStatus(device, "\pUSBHIDMacAllyTenKey: Entered via MacAllyTenKeyDeviceInitialize", device);
  97.     return (OSStatus)noErr;
  98. }
  99.  
  100.  
  101.  
  102. // Termination function
  103. // Called by Expert when driver is being shut down
  104. static OSStatus MacAllyTenKeyFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc)
  105. {
  106. #pragma unused (pDesc)
  107.  
  108. OSStatus myErr;
  109.  
  110.     USBExpertStatus(theDeviceRef, "\pUSBHIDMacAllyTenKey: Finalize", theDeviceRef);
  111.     if (myParamBlock.pFullConfigDescriptor != nil)
  112.     {
  113.         if (myParamBlock.pipeRef)
  114.         {
  115.             USBExpertStatus(theDeviceRef, "\pUSBHIDMacAllyTenKey: Aborting interrupt pipe", theDeviceRef);
  116.             USBAbortPipeByReference(myParamBlock.pipeRef);
  117.         }
  118.             
  119.         myParamBlock.pb.usbReference = theDeviceRef;
  120.         myParamBlock.pb.pbVersion = kUSBCurrentPBVersion;
  121.         myParamBlock.pb.usbFlags = 0;
  122.         myParamBlock.pb.usbRefcon = 0;             
  123.         myParamBlock.pb.usbBuffer = myParamBlock.pFullConfigDescriptor;        
  124.         myParamBlock.pb.usbCompletion = (USBCompletion)-1;
  125.         
  126.         myErr = USBDeallocMem(&myParamBlock.pb);
  127.     };
  128.     return (OSStatus)noErr;
  129. }
  130.  
  131. // Hardware Validation
  132. // Called upon load by Expert
  133. OSStatus MacAllyTenKeyDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
  134. {
  135. #pragma unused (device)
  136. #pragma unused (desc)
  137.  
  138.     return (OSStatus)kUSBNoErr;
  139. }
  140.  
  141.